<template>
	<view class="content">
		<view class="top">
			<view class="box">
				<view class="drawalitemlist">
					<view class="subscription-item" v-if="teamDividendsList.length == 0">
						<u-empty mode="list"></u-empty>
					</view>
					<view class="drawalitem-item" v-for="item in teamDividendsList" v-else>
						<view class="item-left">
							<view class="title">
								我的团队
							</view>
							<view class="time">
								分红时间：{{item.update_time}}
							</view>
						</view>
						<view class="item-right">
							+¥{{item.commission}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				teamDividendsList: [],
				paging: {
					page: 1,
					limit: 10,
				},
				total: null,
			}
		},
		onLoad() {
			this.getTeamDividends()
		},
		onReachBottom() {
			this.getTeamDividends()
		},
		onPullDownRefresh() {
			uni.startPullDownRefresh({
				success: () => this.refresh(),
				complete: () => uni.stopPullDownRefresh()
			})
		},
		methods: {
			getTeamDividends(){
				if (this.teamDividendsList.length == this.total) return
				this.$api.TeamIncomeList(this.paging).then(res => {
					console.log(res)
					this.teamDividendsList = [...this.teamDividendsList, ...res.data.list]
					this.total = res.data.total
					this.paging.page++
				})
			},
			// 刷新列表
			refresh() {
				this.paging.page = 1
				this.total = null
				this.teamDividendsList = []
				this.getTeamDividends()
			},
		}
	}
</script>

<style scoped lang="scss">
	.top {
		padding-top: 20rpx
	}

	.content {
		background: #F5F5F5;
		min-height: 100vh;
		z-index: -1;

		.box {
			padding: 0 30rpx;
		}
	}

	.drawalitemlist {
		padding: 16rpx 30rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		height: 100vh;

		.drawalitem-item {
			display: flex;
			justify-content: space-between;
			padding: 30rpx 0;
			border-bottom: 1rpx solid #dfdfdf;

			.item-left {
				.title {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 36rpx;
					color: #111111;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}

				.time {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 32rpx;
					color: #999999;
					line-height: 34rpx;
					text-align: left;
					font-style: normal;
					margin-top: 8rpx;
				}
			}

			.item-right {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 40rpx;
				color: #D06122;
				line-height: 80rpx;
				text-align: left;
				font-style: normal;
			}
		}
	}
</style>